#include<stdio.h>
#include<string.h>
int main()
{
    //freopen("in.txt","r",stdin);
    char s1[1000005];
    char s2[1000005];
    scanf("%s %s",s1,s2);
    //先求next
    int next[1000005];
    next[0] = 0;
    int S1Len = strlen(s1);
    int S2Len = strlen(s2);
    int now = 0;
    int i = 1;
    while(i < S2Len)
    {
        if(s2[now] == s2[i])
        {
            now++;
            next[i] = now;
            i++;
        }
        else
        if(now)
        {
            now = next[now-1];
        }
        else
        {
            next[i++] = 0;
        }
    }
    int max = 0;
    for(int i = 0; i < S2Len; i++)
    {
        if(max < next[i])
        {
            max = next[i];
        }
    }

    //开始搜索
    int tar = 0;
    int pos = 0;
    while (tar < S1Len)
    {
        if(s1[tar] == s2[pos])
        {
            tar++;
            pos++;
        }
        else if(pos)
        {
            pos = next[pos-1];
        }
        else
        {
            tar++;
        }
        if(pos == S2Len)
        {
            printf("%d\n",tar - pos + 1);
            pos = next[pos-1];
        }
    }
    for(int i = 0;i < S2Len; i++)
    {
        printf("%d ",next[i]);
    }
}